package com.yhd.cloud.service;

import com.google.gson.Gson;
import com.yhd.cloud.feignclient.ProductFeignClient;
import com.yhd.cloud.feignclient.StockFeignClient;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.LongAdder;

/**
 * 订单业务
 *
 * @author yinhuidong3@xiaomi.com
 * @since 2021/7/27
 */
@Service
@Slf4j
public class OrderService {

    @Value("${server.port}")
    private String PORT;
    @Value("${spring.application.name}")
    private String SERVER_NAME;

    @Resource
    private StockFeignClient stockFeignClient;

    @Resource
    private ProductFeignClient productFeignClient;

    @GlobalTransactional
    public String createOrder(Integer skuId, Integer skuNum) {
        productFeignClient.delProductNumById(skuId,skuNum);
        //int a = 10/0;
        stockFeignClient.delProductNumById(skuId,skuNum);
        return "success";
    }

}
